CC = g++
# CC = icc

VERSION = 0.27
	
OBJECTS = TumorGrowthInitialization.o DiffusionSolverSteadyState.o Oxygen.o \
 AdvectTumor.o bessel.o Contour.o Curvature.o DiscreteReinit.o extend.o \
 GaussianFilter.o GhostFluidMethod.o Gradients.o LeastSquares.o NecrosisLevelSets.o \
 Polynomial.o reinit.o Pressure.o TAF.o Microenvironment.o TumorSaveUtilities.o \
 WENO.o
	
OBJECTS_OLD = DiscreteReinit.o Contour.o NecrosisLevelSets.o TumorGrowth.o \
	GaussianFilter.o extend.o Gradients.o WENO.o reinit.o \
	bessel.o CircularTumorSolutions.o TumorGrowthInitialization.o \
	Polynomial.o LeastSquares.o Curvature.o \
	AdvectTumor.o GaussSeidelMethods.o GhostFluidMethod.o Pressure.o \
	TumorSaveUtilities.o Oxygen.o DiffusionSolverSteadyState.o \
	TAF.o Microenvironment.o

# use this for g++
CFLAGS = -O3   -pipe -mmmx -msse -msse2 -s\
             -fomit-frame-pointer -funroll-all-loops -mieee-fp
			 
# use this for older versions of g++
# CFLAGS = -O3 -march=pentiumpro -pipe -mmmx -msse -s \
# -fomit-frame-pointer -funroll-all-loops

# use this for icc
# CFLAGS = -O3 -mcpu=pentium4 -axW -xW -tpp7 -mcpu=pentium4 # -parallel
# CFLAGS = -O0

ARCHIVE_FILE = UCI_TumorGrowth_mingw_source_$(VERSION).zip			 
PUBLIC_ARCHIVE_FILE = UCI_TumorGrowth_mingw_$(VERSION).zip			 

all: $(OBJECTS) 
	cp *.o ..

GaussSeidelMethods.o: GaussSeidelMethods.cpp GaussSeidelMethods.h
	$(CC) $(CFLAGS) -c $(@:.o=.cpp)
	
FindLocalContour.o: FindLocalContour.cpp
	$(CC) $(CFLAGS) -c $(@:.o=.cpp)

Curvature.o: Curvature.cpp
	$(CC) $(CFLAGS) -c $(@:.o=.cpp)

DiscreteReinit.o: DiscreteReinit.cpp
	$(CC) $(CFLAGS) -c DiscreteReinit.cpp

Contour.o: Contour.cpp
	$(CC) $(CFLAGS) -c Contour.cpp
	
NecrosisLevelSets.o: NecrosisLevelSets.cpp
	$(CC) $(CFLAGS) -c NecrosisLevelSets.cpp
	
TumorGrowth.o: TumorGrowth.cpp
	$(CC) $(CFLAGS) -c TumorGrowth.cpp
	
GaussianFilter.o: GaussianFilter.cpp
	$(CC) $(CFLAGS) -c GaussianFilter.cpp
	
extend.o: extend.cpp
	$(CC) $(CFLAGS) -c extend.cpp

Gradients.o: Gradients.cpp
	$(CC) $(CFLAGS) -c Gradients.cpp

WENO.o: WENO.cpp
	$(CC) $(CFLAGS) -c WENO.cpp

reinit.o: reinit.cpp
	$(CC) $(CFLAGS) -c reinit.cpp

bessel.o: bessel.cpp
	$(CC) $(CFLAGS) -c bessel.cpp
	
CircularTumorSolutions.o: CircularTumorSolutions.cpp
	$(CC) $(CFLAGS) -c CircularTumorSolutions.cpp

TumorGrowthInitialization.o: TumorGrowthInitialization.cpp
	$(CC) $(CFLAGS) -c TumorGrowthInitialization.cpp

Polynomial.o: Polynomial.cpp
	$(CC) $(CFLAGS) -c Polynomial.cpp

LeastSquares.o: LeastSquares.cpp	
	$(CC) $(CFLAGS) -c LeastSquares.cpp
	
AdvectTumor.o: AdvectTumor.cpp	
	$(CC) $(CFLAGS) -c AdvectTumor.cpp
	
GhostFluidMethod.o: GhostFluidMethod.cpp GhostFluidMethod.h
	$(CC) $(CFLAGS) -c GhostFluidMethod.cpp

Pressure.o: Pressure.cpp
	$(CC) $(CFLAGS) -c Pressure.cpp
	
TumorSaveUtilities.o: TumorSaveUtilities.cpp
	$(CC) $(CFLAGS) -c TumorSaveUtilities.cpp

Oxygen.o: Oxygen.cpp
	$(CC) $(CFLAGS) -c $(@:.o=.cpp)

DiffusionSolverSteadyState.o: DiffusionSolverSteadyState.cpp
	$(CC) $(CFLAGS) -c $(@:.o=.cpp)	
	
TAF.o: TAF.cpp
	$(CC) $(CFLAGS) -c $(@:.o=.cpp)	
	
Microenvironment.o: Microenvironment.cpp
	$(CC) $(CFLAGS) -c $(@:.o=.cpp)	

clean:
	rm *.o

archive:
	zip $$(date +%b_%d_%Y_%H%M.zip) *.cpp *.h Makefile* UCI*.txt 
	zip $(ARCHIVE_FILE) *.cpp *.h *.o Makefile* UCI*.txt
	zip $(PUBLIC_ARCHIVE_FILE) *.h *.o Makefile* UCI*.txt
